/**
 * Created by XianTao on 2016/7/15
 * <p/>
 * Copyright (c) 2015-2015
 * Apache License
 * Version 2.0, January 2004
 * http://www.apache.org/licenses/
 */
package org.lego.jpa.base.vo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultVo<T> {
    public static final int STATUS_SUCCESS = 0;
    public static final int STATUS_FAIL = -1;

    private Integer status; // 接口调用成功或失败
    private String message; // 接口调用应答的描述
    private T data; // 接口返回的数据
    private Integer dataTotal;  // 如果T为list，此字段存储数据总数（未必是data的长度）

    public ResultVo(String message) {
        this(STATUS_FAIL, message, null, null);
    }

    public ResultVo(T data) {
        this(STATUS_SUCCESS, null, data, null);
    }

    public ResultVo(T data, Integer dataTotal) {
        this(STATUS_SUCCESS, null, data, dataTotal);
    }

    public ResultVo(Integer status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }
}
